package com.test;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class MyWebServer {
	public static final int HTTP_PORT = 80;
	private ServerSocket serversocket;

	public void startServer(int port) {
		try {
			serversocket = new ServerSocket(port);
			System.out.println("Web Server startup on  " + port);
			while (true) {
				Socket socket = serversocket.accept();
				System.out.print("123");
				new MyProcesser(socket).start();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		MyWebServer webserver = new MyWebServer();
		if (args.length == 1) {
			webserver.startServer(Integer.parseInt(args[0]));
		} else {
			webserver.startServer(HTTP_PORT);
		}

	}

}
